package com.benshou.bsoa.service.dingding;

import com.benshou.bsoa.dto.xinchou.req.SalaryAccountRequest;
import com.benshou.bsoa.dto.xinchou.req.SalaryArchiveRequest;
import com.benshou.bsoa.dto.xinchou.res.SalaryAccountResponse;
import com.benshou.bsoa.dto.xinchou.res.SalaryArchiveResponse;
import com.benshou.bsoa.sao.SalaryArchiveClientSao;
import com.benshou.bsoa.utils.CreateAccessTokenUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class SalaryArchiveService {

    @Autowired
    private SalaryArchiveClientSao salaryArchiveClient;

    @Autowired
    private CreateAccessTokenUtil createAccessTokenUtil;

    @Value("${benshou.xinchou.appCode}")
    private String apiCode;

    @Value("${benshou.xinchou.result.appCode}")
    private String apiCodeResult;




    public SalaryArchiveService(SalaryArchiveClientSao salaryArchiveClient) {
        this.salaryArchiveClient = salaryArchiveClient;
    }

    /**
     * 查询员工薪资档案数据
     * @return 响应对象，包含薪资档案数据
     */
    public SalaryArchiveResponse fetchSalaryArchives(SalaryArchiveRequest request) throws Exception {
        request.setApiCode(apiCode);
        return salaryArchiveClient.getSalaryArchives(request,createAccessTokenUtil.getToken());
    }

    /**
     * 工资结算
     *
     * @param request 请求参数对象，包含员工ID列表、分页信息等
     * @return 响应对象，包含薪资档案数据
     */
    public SalaryAccountResponse fetchSalaryAccount(SalaryAccountRequest request) throws Exception {
        request.setApiCode(apiCodeResult);
        return salaryArchiveClient.getSalaryAccount(request, createAccessTokenUtil.getToken());
    }
}